<template>
    <div>
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" v-for="item in newsList" :key="item.id">
                <router-link :to="'/home/newsInfo/' + item.id">
                    <img class="mui-media-object mui-pull-left"
                         :src="item.image">
                    <div class="mui-media-body">
                        <h1>{{item.name}}</h1>
                        <p class='mui-ellipsis'>
                            <span>发表时间：{{item.time | dateFormat}}</span>
                            <span>点击：{{item.count}}次</span>
                        </p>
                    </div>
                </router-link>
            </li>
        </ul>
    </div>
</template>

<script>

    import {Toast} from 'mint-ui'

    export default {
        name: "newsList",
        data() {
            return {
                newsList: []
            }
        },
        created() {
            this.getNewsList()
        },
        methods: {
            getNewsList() {
                //获取新闻列表(本地数据./src/data/newsList.json)
                this.$http.get('./src/data/newsList.json').then(result => {
                    if (result.body.status === "E0") {
                        this.newsList = result.body.data;
                    }else{
                        Toast( result.body.message);
                    }
                })
            }
        },

    }


</script>

<style lang="scss" scoped>
    .mui-table-view {
        li {
            h1 {
                font-size: 14px;
            }
            .mui-ellipsis {
                font-size: 12px;
                color: #23adee;
                display: flex;;
                justify-content: space-between;
            }
        }
    }
</style>